# -*- coding: utf-8 -*-
"""
author:码同学 极光
date:2024/3/17
desc: 
sample: 
"""
import json

number = "20"
print(type(number))
data = int(number) * 3
print(data)
print(type(data))

list_test=['a','a','b','c']
list_test.append('a')
print(list_test)
# print(type(list_test))
# print(len(list_test))
#集合去重
set_test = set(list_test)
print(type(set_test))
list_test =list(set_test)
print(type(list_test))
print(list_test)

list_set={'a','a','b','c'}
print(list_set)
#tuple不可变
list_tuple=tuple(list_test)
# list_tuple.append('a')
print(list_tuple)

person ={
  "name": "张三",
  "age": 25,
  "lunch_fee": 19.5,
  "hope_deposit": 10000000000000,
  "dream_come": True
}
#后台开发 python字典-》字符串-》android /ios
print("------------------------------------")
print(type(person))
print(person.get('name1',''))
print("------------------------------------")
try:
 print(person['name1']) #不存在报错
except:
 pass

print("----------key--------------------------")
for key in person.keys():
  print(key)

print("----------values--------------------------")
for value in person.values():
  print(value)

print("---------- key values--------------------------")
for key in person.keys():
  print(key,person.get(key))

print("---------- key item--------------------------")
print(person.items())
for item in person.items():
  print(item[0],item[1])

print("---------- key item k ,v --------------------------")
for k,v in person.items():
  print(k,v)

print("---------- 嵌套 多个 --------------------------")
list1 =[('name', '张三','age',20), ('age', 25,'age',18), ('lunch_fee', 19.5,'age',15)]
for value in list1:
    print(value[0],value[1],value[2],value[3])
print("---------- 嵌套 多个 第二种 --------------------------")
for c1,c2,c3,c4 in list1:
  print(c1,c2,c3,c4)

#数据库 mysql
#(('name', '张三','age',20),
# ('age', 25,'age',18),
# ('lunch_fee', 19.5,'age',15))

print("------------------------------------")
json_string = '{"name": "John", "age": 30, "city": "New York"}'
json_dic = json.loads(json_string) #python自己能用结构
print(json_dic.get('name'))
print(type(json.dumps(json_dic)))


